package com.digitalchina.lxnsy.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.entity.MyPrizeListVO;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

/**
 * ================================================
 * 项目名称：BigData
 * 类描述：
 * 包名：com.digitalchina.bigdata.viewholder
 * 创建人：郑皓
 * 创建时间：2018/3/23 18:10
 * 修改备注：
 * ================================================
 */

public class MyPrizeListHolder extends BaseViewHolder<MyPrizeListVO> {

    private TextView tvLevel;
    private TextView tvName;
    private TextView tvTime;
    private TextView tvState;


    public MyPrizeListHolder(ViewGroup parent) {
        super(parent, R.layout.item_my_prize_list);
        tvLevel = $(R.id.tv_level);
        tvName = $(R.id.tv_name);
        tvTime = $(R.id.tv_time);
        tvState = $(R.id.tv_state);
    }

    @Override
    public void setData(MyPrizeListVO data) {
        super.setData(data);

        tvLevel.setText(data.getPrizeLevelName() + "");
        tvName.setText(data.getPrizeName() + "");
        tvTime.setText(data.getDeadline() + "  前领取");

        /**
         * 兑奖状态
         * 未兑换 0
         * 已兑换 1
         * 失效 -1
         */
        switch (data.getAwardState()){
            case "0":
                tvState.setText("领取奖品");
                tvState.setTextColor(getContext().getResources().getColor(R.color.colorRed));
                tvState.setBackgroundResource(R.drawable.shape_red_radius_2dp);
                tvTime.setVisibility(View.VISIBLE);
                break;
            case "1":
                tvState.setText("已领取");
                tvState.setTextColor(getContext().getResources().getColor(R.color.colorFontLightGrayB));
                tvState.setBackgroundResource(R.drawable.shape_bg_white_no_stroke);
                tvTime.setVisibility(View.GONE);
                break;
            case "-1":
                tvState.setText("已过期");
                tvState.setTextColor(getContext().getResources().getColor(R.color.colorFontLightGrayB));
                tvState.setBackgroundResource(R.drawable.shape_bg_white_no_stroke);
                tvTime.setVisibility(View.GONE);
                break;
        }

    }

}
